<?php

$serv = new swoole_server("0.0.0.0", 9501);
$serv->set(['task_worker_num' => 4]);
$serv->on("receive", function($serv, $fd, $fromId, $data) {
    $taskId = $serv->task($data);
    echo "异步id: $fromId\n";
});
$serv->on("task", function($serv, $taskId, $fromId, $data) {
    $serv->finish("$data -> ok");
    echo "执行 异步id: $fromId\n";
});
$serv->on("finish", function($serv, $taskId, $data) {
    echo "执行完成";
});
$serv->start();